import React from 'react'
import PropTypes from 'prop-types'
import moment from 'moment'
import {Table, Modal, Switch, Popconfirm} from 'antd'
import classnames from 'classnames'
import {DropOption} from 'components'
import {Link} from 'react-router-dom'
import AnimTableBody from 'components/DataTable/AnimTableBody'
import styles from './ArticleTable.less'

import {timestamp2Date} from 'utils/date'
import {notification} from "antd/lib/index"

const {confirm} = Modal

const ArticlePubTable = ({
                           onDeleteItemPub, onEditItem, isMotion, onShowPubModal, onRemovePub, location, ...tableProps
                         }) => {
//删除
  const handleMenuClick = (record, e) => {
    if (e.key === "1") {
      confirm({
        title: '是否删除当前项？',
        onOk () {
          onDeleteItemPub({
            articleId: record.articleId,
            portletId: record.portletId,
            pgPletId: record.pgPletId,
          })
        },

      })
    }
  }

  const columns = [
    {title: '文章标题', dataIndex: 'title', key: 'titlePub'},
    {title: '发布的栏目', dataIndex: '', key: ''},
    {title: '发布的PORTLET', dataIndex: 'portletId', key: 'portletIdPub'},
    {title: '发布时间', dataIndex: '', key: ''},
    {title: '发布人', dataIndex: 'author', key: 'author'},
    // {title: '审核状态', dataIndex: '', key: ''},
    {
      title: '操作',
      key: 'operationPub',
      width: 100,
      fixed: 'right',
      render: (text, record) => {
        return (<DropOption onMenuClick={e => handleMenuClick(record, e)}
                            menuOptions={[
                              {key: '1', name: '删除'},
                            ]} />)
      },
    },
  ]
  //禁止多选框
  const rowSelection = {
    // fixed:true,
    getCheckboxProps: record => ({
      disabled: true,
    }),
  }
  const CommonBody = (props) => {
    return <tbody {...props} />
  }

  return (
    <Table
      {...tableProps}
      className={classnames(styles.table, {[styles.motion]: false})}
      bordered
      // scroll={{x: 1250}}
      columns={columns}
      simple
      rowKey={record => record.pgPletId}
      rowSelection  = {rowSelection}
      //rowKey={record => record.id}
      components={{
        body: {wrapper: CommonBody},
      }}
    />
  )
}

ArticlePubTable.propTypes = {
  onDeleteItem: PropTypes.func,
  onEditItem: PropTypes.func,
  isMotion: PropTypes.bool,
  location: PropTypes.object,
}

export default ArticlePubTable
